#include <iostream>
#include <string>
using namespace std;

class Operation {
 public:
  double numberA, numberB;
  virtual double getResult() { return 0; }
};

class addOperation : public Operation {
  double getResult() { return numberA + numberB; }
};

class subOperation : public Operation {
  double getResult() { return numberA - numberB; }
};

class mulOperation : public Operation {
  double getResult() { return numberA * numberB; }
};

class divOperation : public Operation {
  double getResult() { return numberA / numberB; }
};

class IFactory {
 public:
  virtual Operation *createOperation() = 0;
};

class AddFactory : public IFactory {
 public:
  Operation *createOperation() { return new addOperation(); }
};

class SubFactory : public IFactory {
 public:
  Operation *createOperation() { return new subOperation(); }
};

class MulFactory : public IFactory {
 public:
  Operation *createOperation() { return new mulOperation(); }
};

class DivFactory : public IFactory {
 public:
  Operation *createOperation() { return new divOperation(); }
};

int main(int argc, char const *argv[]) {
  IFactory *factory = new MulFactory;
  Operation *oper = factory->createOperation();
  oper->numberA = 2;
  oper->numberB = 2;

  cout << oper->getResult() << endl;

  return 0;
}
